// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { game } from "../../../../script/game/control/game";
import { ListViewAdapter } from "../../../../script/util/ListView/ListViewAdapter";
import { ccs } from "../../../../script/util/services";
import { WinBase } from "../../../../script/wins/WinBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends WinBase {

    @property(ListViewAdapter)
    list: ListViewAdapter = null;

    @property(cc.Node)
    rotateBtn: cc.Node = null;
    
    @property(cc.Node)
    gambleIqBtn: cc.Node = null;
    start () {
        this.getData();
        this.touchEndEventScale(this.rotateBtn, () => {
            if(game.playerMgr.reducePower(10) && game.playerMgr.calMoney(-100)) {
                ccs.winMgr.showWin("gambleRotateWin");
                game.playerMgr.achieveFinish("gamble", 1);
            }
        })
        this.touchEndEventScale(this.gambleIqBtn, () => {
            if(game.playerMgr.reducePower(10)) {
                ccs.winMgr.showWin("popGambleIqWin");
                game.playerMgr.achieveFinish("gamble", 1);
            }
        })
    }
    getData() {
        let list = ccs.dataMgr.getGambleList();
        this.list.updateItems(list);
    }
}
